package test.pcs;

import com.payment.lc.pcs.client.wrap.bo.ProductionRedeemAttributes;
import com.payment.lc.pcs.client.wrap.bo.ProductionTimeAttributes;
import com.payment.lc.pcs.client.wrap.service.ProductionWrapService;
import com.payment.lc.pcs.client.wrap.service.ProductionWrapServiceV20;
import com.payment.lc.pcs.common.enums.BizType;
import com.payment.lc.pcs.common.enums.GroupType;
import com.payment.lc.pcs.service.api.AppSettingService;
import com.payment.lc.pcs.service.api.DynamicDataService;
import com.payment.lc.pcs.service.api.ProductionService;
import com.payment.lc.pcs.service.api.fund.JMFundService;
import com.payment.lc.pcs.service.api.modify.InterestRateService;
import com.payment.lc.pcs.service.domain.*;
import com.payment.lc.pcs.service.request.FundTopicRequest;
import com.payment.lc.pcs.service.request.GetFundListReq;
import com.payment.lc.pcs.service.request.InterestRateImportRequest;
import com.payment.lc.pcs.service.response.BaseResponse;
import com.payment.lc.pcs.service.response.FundTopicResp;
import com.payment.lc.pcs.service.response.GetFundListResp;
import com.payment.lc.pcs.service.util.ProductionItem;
import net.rubyeye.xmemcached.MemcachedClient;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import test.BaseTest;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.List;

/**
 * Created on 2016/8/8.
 */
public class Demo2PcsTest2 extends BaseTest {
    private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

    @Autowired
    ProductionService productionService;

    @Autowired
    DynamicDataService dynamicDataService;

    @Autowired
    ProductionWrapService productionWrapService;
    @Autowired
    ProductionWrapServiceV20 productionWrapServiceV20;

    @Autowired
    JMFundService jmFundService;
    @Autowired
    AppSettingService appSettingService;
    @Autowired
    private MemcachedClient pcsProductionMemeryClient;
    @Autowired
    private InterestRateService interestRateService;

    @Test
    public void test() {
        test11();
    }

    void test11() {
        List<Production> list = productionWrapServiceV20.getProductionsStatusInsensitive(GroupType.PCFrontPageGroup, "DingqiHuoqiListMore");

        display(list);

        for (Production production : list) {
            ProductionTimeAttributes timeAttributes = productionWrapService.getProductionTimeAttributes(production, false);
            display(production.getProductionCode());
            display(timeAttributes);
        }

    }


    void test7() {
        Production production = productionWrapService.getProduction("KT10008");
        ProductionRedeemAttributes redeemAttributes = productionWrapService.getProductionRedeemAttributes(production);
        display(redeemAttributes);
    }

    void test8() {
        ListWrapper<ProductionBizInfo> bizs = productionService.getBizs("JM000021");
        display(bizs);
        String viewPeriod = bizs.getList().get(0).getViewPeriod();
        System.out.println(viewPeriod);
    }

    void test3() {
        String channelProdCode = "405";
        String providerCode = "GH";
        String prodCode = dynamicDataService.getProdCodeByChannelProdCode(channelProdCode, providerCode);
        System.out.println(prodCode);
    }

    void test5() {
        String channelProdCode = "405";
        String providerCode = "GH";
        InterestRateImportRequest req = new InterestRateImportRequest();
        req.setChannelProdCode(channelProdCode);
        req.setProviderCode("GH");
        req.setYearYield(new BigDecimal(4.05));
        BaseResponse baseResponse = interestRateService.importInterestRate(req);
        display(baseResponse);
    }

    void test4() {
        FundTopicRequest req = new FundTopicRequest();
        FundTopicResp topicBos = jmFundService.getFundTopicBos(req);
        display(topicBos);
    }

    void test9() {
        Production production = productionWrapService.getProduction("FI16021");
        System.out.println("production = " + production);
        int n = 1;

        long s = System.currentTimeMillis();
        for (int i = 0; i < n; i++) {
            productionWrapService.getProductionRedeemAttributes(production);
        }
        long e = System.currentTimeMillis();

        System.out.println("-------aaaaaaaaaaaaa------------");

        long ss = System.currentTimeMillis();
        for (int i = 0; i < n; i++) {
            productionWrapService.getProductionRedeemAttributes(production, false);
        }
        long ee = System.currentTimeMillis();
        System.out.println(e - s);
        System.out.println(ee - ss);

    }

    void test10() {
        String prodCode = "MP0002";
        ListWrapper<ProductionLimit> wrapper = productionService.getLimit(prodCode, BizType.Fundin);
        print(wrapper);

        ProductionLimit limit1 = wrapper.getList().get(0);
        print(limit1);
    }

    void test1() {
        ListWrapper<ProviderChannel> abc = productionService.getProviderChannelsByProviderCode("HKL");
        print(abc);
    }

    void test2() {
        GetFundListReq req = new GetFundListReq();
        GetFundListResp searchList = jmFundService.getSearchList(req);

        print(searchList);
    }
}